package com.pan.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class TestController {

    @Value("${server.port}")
    private int port;

    @Value("${spring.application.name}")
    private String appName;

    @RequestMapping("/test")
    @ResponseBody
    public String sayHello(HttpServletRequest request, @RequestParam String name){
        StringBuffer stringBuffer = request.getRequestURL();
        String domainName = String.valueOf(stringBuffer).split("/")[2].split(":")[0];

        System.out.println(stringBuffer);
        String result =
                "<h1>helle "+ name + "</h1>"+
                "<div>" +
                        "applcation: "+appName+"<br>"+
                        "port: "+port + "<br>"+
                        "daomain:"+domainName+"<br>"+
                "</div>";
        return result;
    }


}
